/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fy.form.groovy;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.services.UserToken;
import com.seeyon.v3x.services.AuthorityService;
import com.seeyon.v3x.services.flow.FlowService;
import net.sf.json.util.JSONUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Administrator 用户获取流程定义
 */
public class FormSender08 {

    private static final Log logger = LogFactory.getLog(FormSender08.class);

    public static String getFlow(Object object) {

        String result = "";
        try {
            AuthorityService as = (AuthorityService) AppContext.getBean("authorityService");

            UserToken token = as.authenticate("service-admin", "123456");
            logger.info("result:" + token);
            logger.info("result:" + token.getId());

            FlowService fs = (FlowService) AppContext.getBean("BPMService");

            String[] r = fs.getTemplateDefinition(token.getId(), "o_r_01");
//            ServiceResponse r = fs.launchFormCollaboration(token.getId(), "002218", "o_r_01", "测试", data, null, "1", null);

            logger.info("result:" + r.length);
            logger.info("result:" + JSONUtils.valueToString(r));
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        }
        return result;
    }
}
